<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="always" name="unsafe-url"/>
    <title>卢浩&苟盼盼订婚抽奖</title>
    <link rel="stylesheet" type="text/css" href="../static/css/style.css">
    <link rel="stylesheet" href="../static/css/my.css"/>
</head>

<body class="demo2" onload="load()" onunload="load()">
<!-- L K -->
<div class="bg">
    <img src="../static/images/bg.jpg">
</div>

<div class="box">
    <div class="jz">
        <p><b>抽奖</b></p>
        <span class="name">姓名</span><br/>
        <div class="start" id="btntxt" onclick="start()">开始</div>
    </div>

    <div class="zjmd">
        <div class="list">

        </div>
    </div>
</div>

<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/js/covervid.js"></script>
<script type="text/javascript">
    var users = "${users}";
    var xinm = users.split(",");
    var nametxt = $('.name');
    var pcount = xinm.length - 1;//参加人数
    var runing = true;
    var td = 6;//，共6个名额
    var num = 0;
    var t;


    //开始停止
    function start() {
        if (runing) {
            runing = false;
            $('#btntxt').removeClass('start').addClass('stop');
            $('#btntxt').html('停止');

            startNum();
        } else {
            runing = true;
            $('#btntxt').removeClass('stop').addClass('start');
            $('#btntxt').html('开始');
            stop();
            zd();//
        }
//音乐播放暂停

//	 if(audio.paused()){
//
//	        audio.play();//audio.play();// 播放
//	 }
//	 else{
//	         //audio.pause();// 暂停
//	         audio.pause();
//	 }
    }

    //循环参加名单
    function startNum() {
        num = Math.floor(Math.random() * pcount);
        nametxt.html(xinm[num]);
        t = setTimeout(startNum, 0);
    }

    //停止跳动
    function stop() {
        pcount = xinm.length - 1;
        clearInterval(t);
        t = 0;
    }

    //打印列表
    function zd() {
        //打印中奖者名单
        if (td <= 0) {
            alert("投票结束");
        } else {
            $('.list').prepend("<p>" + td + ' ' + xinm[num] + "</p>");
            //将已中奖者从数组中"删除",防止二次中奖
            xinm.splice($.inArray(xinm[num], xinm), 1);
        }
        td = td - 1;
    }

    //音乐
    function a() {
        //window.parent.location.reload();
    }

</script>
<div style="text-align:center;">
</div>
</body>
</html>
